package com.allianz.webapps.controllers;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.allianz.webapps.https.interfaces.util.ObjectUtil;
import com.allianz.webapps.quopojo.Cover;
import com.allianz.webapps.quopojo.PolBase;
import com.allianz.webapps.quopojo.QuoBase;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;

//http://localhost:8080/pad_marketing/main/quoDelete.action
//http://localhost:8080/pad_marketing/main/quoDelCover.action
//http://localhost:8080/pad_marketing/main/quoDelPolicy.action

@Controller
@RequestMapping(value="main")
public class QuoDeleteController {

	@Autowired
	private ObjectMapper objectMapper;
	@Autowired
	private ObjectUtil objectUtil;
	
	/**
	 * 删除报价
	 */
	@RequestMapping(value="quoDelete")
	@ResponseBody
	public String quoDelete(@RequestParam(value="jsonParam") String jsonParam,HttpServletRequest request,HttpServletResponse response)
			throws Exception{
		List<QuoBase> quoBases=objectMapper.readValue(jsonParam,new TypeReference<List<QuoBase>>(){});
		String body=objectUtil.requestParam(quoBases, "quo.delete");
		return body;
	}
	
	
	
	/**
	 * 删除保单
	 */
	@RequestMapping(value="quoDelPolicy")
	@ResponseBody
	public String quoDelPolicy(@RequestParam(value="jsonParam") String jsonParam,HttpServletRequest request,HttpServletResponse response)
			throws Exception{
		PolBase obj=objectMapper.readValue(jsonParam,PolBase.class);
		String body=objectUtil.requestParam(obj, "quo.delPolicy");
		return body;
	}
	
}
